<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>基于人脸识别的移动考勤后台管理系统</title>
    <link rel="stylesheet" href="./layui-ui/dist/css/layui.css">
</head>
<body class="layui-layout-body">
<!--编辑用户-->
<form class="layui-form" id="registerUserEdit" style="display:none">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="on" class="layui-input" id="username" style="width:100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="on" class="layui-input" id="password" style="width:100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入部门" autocomplete="on" class="layui-input" id="department_name" style="width:100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职位</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入职位" autocomplete="on" class="layui-input" id="role" style="width:100px">
        </div>
    </div>

</form>
<!--添加考勤配置-->
<form class="layui-form" id="addConfig" style="display:none">
    <div class="layui-form-item">
        <label class="layui-form-label">签到时间</label>
        <div class="layui-input-block">
            <input type="text" name="username" required  lay-verify="required" placeholder="请输入签到时间" autocomplete="on" class="layui-input" id="start_time" style="width:160px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">签退时间</label>
        <div class="layui-input-block">
            <input type="text" name="password" required  lay-verify="required" placeholder="请输入签退时间" autocomplete="on" class="layui-input" id="end_time" style="width:160px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">经度</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入经度" autocomplete="on" class="layui-input" id="longitude" style="width:160px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">纬度</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入纬度" autocomplete="on" class="layui-input" id="latitude" style="width:160px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入地址" autocomplete="on" class="layui-input" id="address" style="width:160px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">考勤范围</label>
        <div class="layui-input-block">
            <input type="text" name="department_name" required  lay-verify="required" placeholder="请输入考勤的有效范围" autocomplete="on" class="layui-input" id="address_range" style="width:160px">
        </div>
    </div>
</form>

<!--添加管理员-->
<form class="layui-form" id="addVip" style="display:none">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="on" class="layui-input" id="vipName" style="width:100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="on" class="layui-input" id="vipPassword" style="width:100px">
        </div>
    </div>
</form>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">移动考勤后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                </a>
            </li>
            <li class="layui-nav-item" type="button"><a onclick="logout()">退出</a></li>
        </ul>
    </div>

    <div class="layui-tab" lay-filter="test">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="11">员工管理</li>
            <li lay-id="22">考勤管理</li>
            <li lay-id="33">考勤统计</li>
            <li lay-id="44">考勤配置</li>
            <li lay-id="55">申请查询</li>
            <li lay-id="66">管理员管理</li>
            <li lay-id="66">发布通知</li>


        </ul>
        <div class="layui-tab-content">

            <div class="layui-tab-item layui-show">
                <table class="layui-hide" id="demo11" lay-filter="test1"></table>
                <script type="text/html" id="barDemo">
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">审核</a>
                    <a class="layui-btn layui-btn-xs" lay-event="edit" data-method="offset" data-type="auto">编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
            </div>

            <div class="layui-tab-item">
                <table class="layui-hide" id="demo22" lay-filter="test2"></table>
                <script type="text/html" id="barDemo22">
                    <a class="layui-btn layui-btn-xs" lay-event="detail">审核</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
            </div>

            <div class="layui-tab-item">
                <table class="layui-hide" id="demo33" lay-filter="test3"></table>
            </div>
            <div class="layui-tab-item">
                <table class="layui-hide" id="demo44" lay-filter="test3"></table>
                <script type="text/html" id="barDemo33">
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="insert">新增</a>
                    <a class="layui-btn layui-btn-xs" lay-event="edit">启用</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
            </div>

            <div class="layui-tab-item">
                <table class="layui-hide" id="demo55" lay-filter="test4"></table>
                <script type="text/html" id="barDemo44">
                    <a class="layui-btn  layui-btn-xs" lay-event="pass">同意</a>
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="unPass">不同意</a>
                </script>
            </div>

            <div class="layui-tab-item">
                <table class="layui-hide" id="demo66" lay-filter="test5"></table>
                <script type="text/html" id="barDemo55">
                    <a class="layui-btn  layui-btn-xs" lay-event="add">添加</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
            </div>

            <div class="layui-tab-item">
                <form class="layui-form" id="demo77" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">通知内容</label>
                        <div class="layui-input-block">
                            <textarea name="desc" placeholder="请输入内容" lay-verify="required" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formDemo">发布通知</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>

    <script src="./layui-ui/dist/layui.js"></script>
    <script>
        function logout(){
            window.location.replace('logout');

        };
        var user_ID;
        //JavaScript代码区域
        layui.use('element', function () {
            var $ = layui.jquery
                , element = layui.element
                , laypage = layui.laypage; //分页 //Tab的切换功能，切换事件监听等，需要依赖element模块
            //Hash地址的定位
            var layid = location.hash.replace(/^#test=/, '');
            element.tabChange('test', layid);

            element.on('tab(test)', function (elem) {
                location.hash = 'test=' + $(this).attr('lay-id');
            });
        });

        layui.use(['table','form'], function () {
            var $ = layui.$
                , element = layui.element;
            var table1 = layui.table;
            var table2 = layui.table;
            var table3 = layui.table;
            var table4 = layui.table;
            var table5 = layui.table;
            var table6 = layui.table;
            var table7 = layui.form;


            //监听Tab切换
            element.on('tab(demo11)', function (data) {
                layer.tips('切换了 ' + data.index + '：' + this.innerHTML, this, {
                    tips: 1
                });
            });

            //第一个实例  员工管理
            table1.render({
                elem: '#demo11'
                , height: 500
                , url: '/api/selectAll1' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                // ,totalRow: true //开启合计行
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 'user_id', title: 'ID', width: 80, sort: true, fixed: 'left', totalRow: true}
                        , {field: 'picture', title: '头像', width: 60, align: "left", sort: false, templet:function(d){console.log(d); return'<div><img src="/api'+d.picture+'" style="height: 30px;max-width: 30px;" ></div>'}}
                        , {field: 'userName', title: '用户名', width: 90, sort: true, totalRow: true}
                        , {field: 'password', title: '密码', width: 80, sort: true}
                        , {field: 'name', title: '用户姓名', width: 80, sort: true, totalRow: true}
                        , {field: 'department_name', title: '部门', width: 150}
                        , {field: 'role', title: '职位', width: 150}
                        , {field: 'tel', title: '电话', width: 120}
                        , {field: 'email', title: '邮箱', width: 170}
                        , {field: 'create_time', title: '更新时间', width: 120}
                        , {field: 'status', title: '状态', width: 80, sort: true, totalRow: true}
                        , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo'}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                     console.log(res);

                }
            });

            //第二个实例 考勤管理
            table2.render({
                elem: '#demo22'
                , height: 500
                , url: '/api/allUserAtt' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 'id', title: '考勤ID', width: 90, sort: true, fixed: 'left', totalRowText: '合计：'}
                        , {field: 'user_id', title: '用户ID', width: 80}
                        , {field: 'date', title: '日期', width: 120, sort: true, totalRow: true}
                        , {field: 'time', title: '时间', width: 120, sort: true}
                        , {field: 'address', title: '地址', width: 250, sort: true, totalRow: true}
                        , {field: 'longitude', title: '经度', width: 110}
                        , {field: 'latitude', title: '纬度', width: 110}
                        , {field: 'flag', title: '标志', width: 80}
                        , {field: 'status', title: '状态', width: 80, sort: true, totalRow: true}
                        , {field: 'described', title: '描述', width: 120, sort: true, totalRow: true}
                        , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo22'}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                    // console.log(res);
                }
            });
            table6.render({
                elem: '#demo33'
                , height: 500
                , url: '/api/Statics/selectAll' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 's_id', title: 'ID', width: 80, sort: true, fixed: 'left', totalRowText: '合计：'}
                        , {field: 'user_id', title: '用户ID', width: 80}
                        , {field: 'name', title: '用户名', width: 80}
                        , {field: 'date', title: '年月', width: 90, sort: true, totalRow: true}
                        , {field: 'work_day', title: '考勤次数', width: 80, sort: true}
                        , {field: 'later_day', title: '迟到次数', width: 150, sort: true, totalRow: true}
                        , {field: 'early_day', title: '早退次数', width: 110}
                        , {field: 'travel_day', title: '出差次数', width: 110}
                        , {field: 'travel_time', title: '时长(h)', width: 80}
                        , {field: 'leave_day', title: '请假次数', width: 80, sort: true, totalRow: true}
                        , {field: 'leave_time', title: '时长(h)', width: 80, sort: true, totalRow: true}
                        , {field: 'absent_day', title: '缺勤次数', width: 120, sort: true, totalRow: true}
                        , {field: 'over_day', title: '加班次数', width: 120, sort: true, totalRow: true}
                        , {field: 'over_time', title: '时长(h)', width: 120, sort: true, totalRow: true}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                    // console.log(res);
                }
            });


            //第三个实例 考勤配置
            table3.render({
                elem: '#demo44'
                , height: 500
                , url: '/api/config/all' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 'c_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                        , {field: 'start_time', title: '签到时间', width: 90}
                        , {field: 'end_time', title: '签退时间', width: 100, sort: true, totalRow: true}
                        , {field: 'longitude', title: '经度', width: 110, sort: true}
                        , {field: 'latitude', title: '纬度', width: 110, sort: true, totalRow: true}
                        , {field: 'address', title: '地址', width: 200}
                        , {field: 'address_range', title: '距离范围', width: 80}
                        , {field: 'status', title: '状态', width: 60}
                        , {field: 'create_by', title: '创建', width: 100}
                        , {field: 'create_time', title: '创建时间', width: 150, sort: true, totalRow: true}
                        , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo33'}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                    // console.log(res);
                }
            });

            //第四个实例 申请查询
            table4.render({
                elem: '#demo55'
                , height: 500
                , url: '/api/apply/all' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 'app_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                        , {field: 'user_id', title: '用户ID', width: 80}
                        , {field: 'name', title: '用户姓名', width: 80}
                        , {field: 'a_type', title: '申请类型', width: 90, sort: true, totalRow: true}
                        , {field: 'a_reason', title: '原因', width: 150, sort: true}
                        , {field: 'a_date', title: '时间', width: 150, sort: true, totalRow: true}
                        , {field: 'a_startDate', title: '开始时间', width: 120}
                        , {field: 'a_endDate', title: '结束时间', width: 120}
                        , {field: 'a_hours', title: '时长（小时）', width: 80}
                        , {field: 'a_status', title: '状态', width: 80}
                        , {field: 'approvedbyId', title: '审核人ID', width: 80}
                        , {field: 'approvedby', title: '审核人', width: 100, sort: true, totalRow: true}
                        , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo44'}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                    // console.log(res);
                }
            });

            //第五个实例 管理员
            table5.render({
                elem: '#demo66'
                , height: 500
                , url: '/api/user/my/list' //数据接口
                , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , page: true //开启分页
                , cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'}
                        , {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                        , {field: 'name', title: '用户名', width: 120}
                        , {field: 'role', title: '管理员', width: 80}
                        , {field: 'ip', title: '最近ip', width: 150, sort: true}
                        , {field: 'lastLoginTime', title: '最近登录时间', width: 200, sort: true, totalRow: true}
                        , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo55'}
                    ]
                ]
                , parseData: function (res) { //res 即为原始返回的数据
                    // console.log(res);
                }
            });

            //
            table7.on('submit(formDemo)', function(data){
                layer.msg(JSON.stringify(data.field));
                console.log(data);
                $.ajax({
                    url: '/api/web/publish',
                    type: 'get',
                    data: {'title': data.field.title, 'content': data.field.desc},//向服务端发送删除的id
                    success: function (suc) {
                        if (suc.success == true) {
                            layer.msg("发布成功", {icon: 1});
                        } else {
                            layer.msg("发布失败", {icon: 5});
                        }
                    }
                });
                return false;
            });

            //table1监听行工具事件
            table1.on('tool(test1)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event;
                console.log("0000000000")//获得 lay-event 对应的值
                if (layEvent === 'detail') {
                    //layer.msg('我的  审核操作');
                    $.ajax({
                        url: '/api/updateUserStatus',
                        type: 'get',
                        data: {'user_id': data.user_id, 'status': 1},//向服务端发送删除的id
                        success: function (suc) {
                            // console.log(suc.success);
                            if (suc.success == true) {
                                /*
                                * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++刷新行
                                * */
                                //layer.refresh;
                                //layer.close(index);
                                // console.log(index);
                                //location.reload(true);
                                obj.update({
                                    status: 1
                                })
                                layer.msg("审核成功", {icon: 1});
                            } else {
                                layer.msg("审核失败", {icon: 5});
                            }
                        }
                    });

                } else if (layEvent === 'del') {
                    layer.confirm('真的删除这个用户吗？', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/deleteUser',
                            type: 'get',
                            data: {'user_id': data.user_id},//向服务端发送删除的id
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    layer.close(index);
                                    // console.log(index);
                                    layer.msg("删除成功", {icon: 1});
                                } else {
                                    layer.msg("删除失败", {icon: 5});
                                }
                            }
                        });
                    });
                } else if (layEvent === 'edit') {
                    layer.open({
                        type:1,
                        area:['280px','330px'],
                        title: '员工管理-编辑'
                        ,content: $("#registerUserEdit"),
                        shade: 0,
                        btn: ['提交', '取消']
                        ,btn1: function(index, layero){
                            user_ID = obj.data.user_id;
                            obj.data.userName=$("#username").val();
                            obj.data.password=$("#password").val();
                            obj.data.department_name=$("#department_name").val();
                            obj.data.role=$("#role").val();
                            $.ajax({
                                url: '/api/web/updateUser',
                                type: 'get',
                                data: obj.data,//向服务端发送删除的id
                                success: function (suc) {
                                    console.log(suc);
                                    if (suc.success == true) {
                                        layer.msg("编辑成功", {icon: 1});
                                        location.reload();
                                        layer.closeAll();
                                    } else {
                                        layer.msg("编辑失败", {icon: 5});
                                    }
                                }
                            });
                        },
                        btn2: function(index, layero){
                            // alert("2222");
                            layer.closeAll();
                            return false;
                        },
                        cancel: function(layero,index){
                            layer.closeAll();
                            location.reload();
                        }
                    });

                }
            });
            //table2监听行工具事件
            table2.on('tool(test2)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent === 'detail') {
                    //向服务端发送删除指令
                    $.ajax({
                        url: '/api/web/updat/att',
                        type: 'get',
                        data: {'id': data.id},//向服务端发送删除的id
                        success: function (suc) {
                            // console.log(suc.success);
                            if (suc.success == true) {
                                // obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                // layer.close(index);
                                //console.log(index);
                                obj.update({
                                    status: 1, described: "正常"
                                })
                                layer.msg("审核成功", {icon: 1});
                            } else {
                                layer.msg("审核失败", {icon: 5});
                            }
                        }
                    });

                } else if (layEvent === 'del') {
                    layer.confirm('真的删除这条考勤记录吗', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/delete/att',
                            type: 'get',
                            data: {'id': data.id},//向服务端发送删除的id
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    layer.close(index);
                                    // console.log(index);
                                    layer.msg("删除成功", {icon: 1});
                                } else {
                                    layer.msg("删除失败", {icon: 5});
                                }
                            }
                        });
                    });
                } else if (layEvent === 'edit') {
                    layer.msg('编辑操作');
                }
            });

            //table3 监听行工具事件
            table3.on('tool(test3)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent === 'insert') {
                    layer.open({
                        type:1,
                        area:['330px','450px'],
                        title: '添加考勤配置-编辑'
                        ,content: $("#addConfig"),
                        shade: 0,
                        btn: ['提交', '取消']
                        ,btn1: function(index, layero){
                            var start_time=$("#start_time").val();
                            var end_time=$("#end_time").val();
                            var longitude=$("#longitude").val();
                            var latitude=$("#latitude").val();
                            var address=$("#address").val();
                            var address_range=$("#address_range").val();
                            $.ajax({
                                url: '/api/config/insert',
                                type: 'get',
                                data: {'start_time':start_time,'end_time':end_time,'longitude':longitude,'latitude':latitude,'address':address,'address_range':address_range},//向服务端发送删除的id
                                success: function (suc) {
                                    console.log(suc);
                                    if (suc.success == true) {
                                        layer.msg("添加成功", {icon: 1});
                                        location.reload();
                                        layer.closeAll();
                                    } else {
                                        layer.msg("添加失败", {icon: 5});
                                    }
                                }
                            });
                        },
                        btn2: function(index, layero){
                            // alert("2222");
                            layer.closeAll();
                            return false;
                        },
                        cancel: function(layero,index){
                            layer.closeAll();
                            location.reload();
                        }
                    });

                } else if (layEvent === 'edit') {
                    layer.confirm('确定启用此配置吗', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/config/updateStatus',
                            type: 'get',
                            data: {'c_id': data.c_id},//向服务端发送删除的id
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    //obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    //layer.close(index);
                                    // console.log(index);

                                    layer.msg("启用成功成功", {icon: 1});
                                    location.reload(true);

                                } else {
                                    layer.msg("启用失败失败", {icon: 5});
                                }
                            }
                        });
                    });
                } else if (layEvent === 'del') {
                    layer.confirm('确定删除此配置吗', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/config/delete',
                            type: 'get',
                            data: {'c_id': data.c_id},//向服务端发送删除的id
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    //obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    //layer.close(index);
                                    // console.log(index);

                                    layer.msg("删除成功", {icon: 1});
                                    location.reload(true);

                                } else {

                                    if (suc.data = 1) {
                                        layer.msg("删除失败,无法删除启用的配置", {icon: 5});
                                    } else {
                                        layer.msg("删除失败", {icon: 5});
                                    }

                                }
                            }
                        });
                    });
                }
            });
            //table4 监听行工具事件
            table4.on('tool(test4)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值

                if (layEvent === 'pass') {
                    layer.confirm('确定通过此申请吗', function (index) {
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/web/approve',
                            type: 'get',
                            data: {'app_id': data.app_id, "a_status": 1},
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    // obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    // layer.close(index);
                                    //console.log(index);
                                    if(data.a_type=="补卡"){
                                        insertAtt();
                                    }else {
                                        obj.update({
                                            a_status: 1
                                        })
                                        layer.msg("已通过此申请", {icon: 1});
                                    }
                                } else {
                                    layer.msg("通过失败", {icon: 5});
                                }
                            }

                        });
                    });
                    function insertAtt() {
                        $.ajax({
                            url: '/api/web/insertAtt',
                            type: 'get',
                            data: {'user_id': data.user_id, "date": data.a_startDate,"time":data.a_endDate,"address":data.a_startAddress,"longitude":'0.0',"latitude":'0.0',"flag":1},
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    //obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    //layer.close(index);
                                    // console.log(index);
                                    obj.update({
                                        a_status: 1
                                    })
                                    layer.msg("已通过此申请", {icon: 1});
                                } else {
                                    obj.update({
                                        a_status: 1
                                    })
                                    layer.msg("通过成功，但无法插入此条考勤记录，当天已存在考勤记录，请删除后再试", {icon: 5});
                                }
                            }
                        });
                    }
                } else if (layEvent === 'unPass') {
                    layer.confirm('确定此申请不通过吗', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/web/approve',
                            type: 'get',
                            data: {'app_id': data.app_id, "a_status": 2},
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    //obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    //layer.close(index);
                                    // console.log(index);

                                    layer.msg("此申请未通过", {icon: 1});
                                    location.reload(true);

                                } else {
                                    layer.msg("操作失败", {icon: 5});
                                }
                            }
                        });

                    });
                }
            });
            //table5 监听行工具事件
            table5.on('tool(test5)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent === 'add') {
                    layer.open({
                        type:1,
                        area:['280px','330px'],
                        title: '添加管理员-编辑'
                        ,content: $("#addVip"),
                        shade: 0,
                        btn: ['提交', '取消']
                        ,btn1: function(index, layero){
                            var name=$("#vipName").val();
                            var password=$("#vipPassword").val();
                            $.ajax({
                                url: '/api/user/mysave',
                                type: 'post',
                                data: {'name':name,'password':password},//向服务端发送删除的id
                                success: function (suc) {
                                    console.log(suc);
                                    if (suc.success == true) {
                                        layer.msg("添加成功", {icon: 1});
                                        location.reload();
                                        layer.closeAll();
                                    } else {
                                        layer.msg("添加失败", {icon: 5});
                                    }
                                }
                            });
                        },
                        btn2: function(index, layero){
                            // alert("2222");
                            layer.closeAll();
                            return false;
                        },
                        cancel: function(layero,index){
                            layer.closeAll();
                            location.reload();
                        }
                    });
                } else if (layEvent === 'del') {
                    layer.confirm('确定删除管理员吗', function (index) {
                        console.log(data);
                        //向服务端发送删除指令
                        $.ajax({
                            url: '/api/user/mydelete',
                            type: 'get',
                            data: {'id': data.id},//向服务端发送删除的id
                            success: function (suc) {
                                // console.log(suc.success);
                                if (suc.success == true) {
                                    //obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    //layer.close(index);
                                    // console.log(index);
                                    layer.msg("删除成功", {icon: 1});
                                    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    layer.close(index);
                                } else {
                                    layer.msg("删除失败", {icon: 5});
                                }
                            }
                        });
                    });
                }
            });
            //分页
            // laypage.render({
            //   elem: 'demo11' //分页容器的id
            //   ,count: 100 //总页数
            //   ,skin: '#1E9FFF' //自定义选中色值
            //   ,skip: true //开启跳页
            //   ,jump: function(obj, first){
            //     if(!first){
            //       layer.msg('第'+ obj.curr +'页', {offset: 'b'});
            //     }
            //   }
            // });

        });

    </script>
</body>
</html>